Add fields PATH_SPEED_KPH and PATH_SPEED_MPH to xcsv.
authoroliskoli <oliskoli>
Sun, 15 Jul 2007 17:09:09 +0000 (17:09 +0000)
committeroliskoli <oliskoli>
Sun, 15 Jul 2007 17:09:09 +0000 (17:09 +0000)
csv_util.c
defs.h
xmldoc/chapters/styles.xml

index e3389376f4850dec55d3e80ce4d5e4653b52bbf6..3f87bc9ee58b9c5fd4cd701cc667e6684afc7f9e 100644 (file)
@@ -911,6 +911,12 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp)
     if (strcmp(fmp->key, "PATH_SPEED") == 0) {
        WAYPT_SET(wpt, speed, atof(s));
     } else
+    if (strcmp(fmp->key, "PATH_SPEED_KPH") == 0) {
+       WAYPT_SET(wpt, speed, KPH_TO_MPS(atof(s)));
+    } else
+    if (strcmp(fmp->key, "PATH_SPEED_MPH") == 0) {
+       WAYPT_SET(wpt, speed, MPH_TO_MPS(atof(s)));
+    } else
     if (strcmp(fmp->key, "PATH_COURSE") == 0) {
        WAYPT_SET(wpt, course, atof(s));
     } else
@@ -1420,6 +1426,12 @@ xcsv_waypt_pr(const waypoint *wpt)
        if (strcmp(fmp->key, "PATH_SPEED") == 0) {
             writebuff( buff, fmp->printfc, wpt->speed );
        } else
+       if (strcmp(fmp->key, "PATH_SPEED_KPH") == 0) {
+            writebuff( buff, fmp->printfc, MPS_TO_KPH(wpt->speed));
+       } else
+       if (strcmp(fmp->key, "PATH_SPEED_MPH") == 0) {
+            writebuff( buff, fmp->printfc, MPS_TO_MPH(wpt->speed));
+       } else
        if (strcmp(fmp->key, "PATH_COURSE") == 0) {
             writebuff( buff, fmp->printfc, wpt->course );
        } else
diff --git a/defs.h b/defs.h
index c62d0718b1aeb677cdcaada8a4f2f7271e7abdd5..9759d34b70a0c09e82dc3a3bb58e9262148815f4 100644 (file)
--- a/defs.h
+++ b/defs.h
 #define SECONDS_PER_HOUR (60L*60)
 #define SECONDS_PER_DAY (24L*60*60)
 
+/* meters/second to kilometers/hour */
+#define MPS_TO_KPH(a) ((double)(a)*SECONDS_PER_HOUR/1000)
+/* meters/second to miles/hour */
+#define MPS_TO_MPH(a) (METERS_TO_MILES(a) * SECONDS_PER_HOUR)
+/* kilometers/hour to meters/second */
+#define KPH_TO_MPS(a) ((double)(a)*1000/SECONDS_PER_HOUR)
+/* miles/hour to meters/second */
+#define MPH_TO_MPS(a) (MILES_TO_METERS(a) / SECONDS_PER_HOUR)
+
 /*
  * Snprintf is in SUS (so it's in most UNIX-like substance) and it's in 
  * C99 (albeit with slightly different semantics) but it isn't in C89.   
index 199e91b6aff292115206cfd8caab8d6c23c56b55..503555096205c398249241d6648e4d3f4f5fb95e 100644 (file)
@@ -1057,6 +1057,30 @@ example:
 </screen>
 </section>
 
+<section id="style_def_pathspeed_kph">
+<title>PATH_SPEED_KPH</title>
+<para>
+   Like PATH_SPEED but means kilometers per hour.
+</para>
+<para>
+example:
+</para>
+<screen format="linespecific">   PATH_SPEED_KPH,"","%.1f"
+</screen>
+</section>
+
+<section id="style_def_pathspeed_mph">
+<title>PATH_SPEED_MPH</title>
+<para>
+   Like PATH_SPEED but means miles per hour.
+</para>
+<para>
+example:
+</para>
+<screen format="linespecific">   PATH_SPEED_MPH,"","%.1f"
+</screen>
+</section>
+
 <section id="style_def_pathcourse">
 <title>PATH_COURSE</title>
 <para>